﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ZOVNP.Model.Abstracts;

namespace ZOVNP.Engine
{
    [DomainObject(typeof(ICustomer))]
    public partial class Customer : ICustomer
    {
        private IDomainCollection<IOrder> _ordersLocker;

        public Customer()
        {
            _ordersLocker = new SmartCollection<Order, IOrder>(this, Orders);
        }

        IDomainCollection<IOrder> ICustomer.Orders
        {
            get { return _ordersLocker; }
        }

        public override bool CheckSelfProperties()
        {
            return
                !string.IsNullOrWhiteSpace(FirstName) &&
                !string.IsNullOrWhiteSpace(Surname) &&
                !string.IsNullOrWhiteSpace(PhoneNumber);
        }

        public override string ToString()
        {
            return string.Format("{0} {1} {2}", FirstName, LastName, Surname);
        }
    }
}
